﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HeathCareSystem.wuc
{
    public partial class wucDangNhap : System.Web.UI.UserControl
    {
        DataProvider d = new DataProvider();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            String strSQL = "SELECT * FROM TaiKhoan WHERE (TenDangNhap = '" + txtTaiKhoan.Text + "') AND (MatKhau = '" + txtMatKhau.Text + "')";

            DataTable dt = d.ExecuteQuery(strSQL);
            if (dt.Rows.Count > 0)
            {
                Session["isLogin"] = true;
                Session["MaTaiKhoan"] = dt.Rows[0]["MaTaiKhoan"].ToString();
                Session["TenDangNhap"] = dt.Rows[0]["TenDangNhap"].ToString();

                Page_Load(sender, e);
            }
            else
                lblError.Text = "Tên Đăng Nhập hay Mật Khẩu sai";
        }
    }
}